<%= render partial: 'spree/admin/shared/order_tabs', locals: { current: :payments } %>

<% content_for :page_actions do %>
  <% if @order.outstanding_balance? && can?(:create, Spree::Payment) %>
    <span id="new_payment_section">
      <%= button_link_to Spree.t(:new_payment), new_admin_order_payment_url(@order), class: "btn-success", icon: 'add.svg' %>
    </span>
  <% end %>
<% end %>

<% content_for :page_title do %>
  / <%= Spree.t(:payments) %>
<% end %>

<% if @order.outstanding_balance? %>
  <div class="alert alert-info outstanding-balance">
    <%= @order.outstanding_balance < 0 ? Spree.t(:credit_owed) : Spree.t(:balance_due) %>: <strong><%= @order.display_outstanding_balance %></strong>
  </div>
<% end %>

<% if @payments.any? %>
  <div data-hook="payment_list" class="mb-3 table-responsive">
    <%= render partial: 'list', locals: { payments: @payments } %>
  </div>

  <% if @refunds.any? %>
    <fieldset data-hook="payment_list" class="no-border-bottom">
      <legend><%= Spree.t(:refunds) %></legend>
      <%= render partial: 'spree/admin/shared/refunds', locals: { refunds: @refunds, show_actions: true } %>
    </fieldset>
  <% end %>

<% else %>
  <div class="alert alert-info no-objects-found"><%= Spree.t(:order_has_no_payments) %></div>
<% end %>

<%= render partial: 'spree/admin/shared/order_summary' %>
